<template>
	<view style="border-radius: 10px;background-color: #fff;padding: 20px;">
		<view style="display: flex;justify-content: space-between;align-items: center;">
			<view style="display: flex;justify-content: space-between;align-items: center;gap: 10px;">
				<tn-avatar :url="sConf.pics + place.logo" size="lg"></tn-avatar>
				<view style="display: flex;flex-direction: column;justify-content: space-between;height: 100%;">
					<view class="textView" style="font-weight: bold;font-size: larger;">{{ place.nicename }}
					</view>
					<view style="display: flex;">
						<tn-rate v-model="place.rate" readonly allow-half :min="0" :max="5" size="16px"
							activeColor="#d97706">数据</tn-rate>
						<view style="font-style: italic;color: #d97706;font-size: small;">{{ place.rate }}分
						</view>
					</view>
				</view>
			</view>
			<view class="">
				<button v-if="follow" style="font-size: smaller;background-color: #dd524d;" @click="likeChange"><tn-icon
						name="add" color="#fff"></tn-icon><text style="color: #fff;">关注</text></button>
				<button v-if="stroll" style="font-size: smaller;background-color: #dd524d;"
					@click="placeChange"><tn-icon name="login" color="#fff"></tn-icon><text
						style="color: #fff;">进店</text></button>
			</view>
		</view>
		<view style="display: flex;justify-content: center;align-items: flex-end;gap: 40px;padding-top: 10px;">
			<view v-if="place.auth" style="display: flex;flex-direction: column;align-items: center;">
				<tn-icon name="safe" color="#4cd964" size="40"></tn-icon>
				<text style="font-size: smaller;color: #aaa;">企业认证</text>
			</view>
			<view v-else style="display: flex;flex-direction: column;align-items: center;">
				<tn-icon name="safe" color="#888" size="40"></tn-icon>
				<text style="font-size: smaller;color: #aaa;">未认证</text>
			</view>
			<view style="display: flex;flex-direction: column;justify-content: space-between;align-items: center;">
				<text style="font-size: large;font-weight: bold;">2890</text>
				<text style="font-size: smaller;color: #aaa;">销量</text>
			</view>
			<view style="display: flex;flex-direction: column;justify-content: space-between;align-items: center;">
				<text style="font-size: large;font-weight: bold;">12K</text>
				<text style="font-size: smaller;color: #aaa;">粉丝</text>
			</view>
			<view style="display: flex;flex-direction: column;justify-content: space-between;align-items: center;">
				<text style="font-size: large;font-weight: bold;">132</text>
				<text style="font-size: smaller;color: #aaa;">动态</text>
			</view>
		</view>
	</view>
</template>

<script>
import utils from '@/common/utils';
export default {
	name: "sub-shoped-card",
	data() {
		return {
			sConf: getApp().globalData,
		};
	},
	props: {
		place: {
			type: Object
		},
		follow: { // 关注按钮
			type: Boolean,
			default: false
		},
		stroll: { // 进店
			type: Boolean,
			default: false
		}
	},
	methods: {
		likeChange() {
			console.log('关注事件');
			let host = this.sConf.host + '/weapps/favChange/';
			let token = this.sConf.token || ''
			let data = {
				sid: this.sConf.auth.id,
				pid: this.place.id,
				status: 1
			}
			utils.authenticatorOnPost(host, token, data).then(res => {
				console.log('关注店铺', res);
				uni.showToast({
					icon: 'success',
					title: '关注店铺成功'
				})
			}).catch(err => {
				console.log('关注店铺__失败', err);
				uni.showToast({
					icon: 'error',
					title: '关注店铺失败'
				})
			})
		},
		placeChange() {
			console.log('进店事件');
			uni.redirectTo({
				url: '/pageb/shoped/shoped?pid=' + this.place.id
			})
		}
	}
}
</script>

<style></style>